import React, { Suspense } from 'react';
import ReactDOM from 'react-dom/client';
import {
  createBrowserRouter,
  RouterProvider,
} from "react-router-dom";

const IndexPage = React.lazy(() => import('./pages/index'));
const RecordPage = React.lazy(() => import('./pages/bangumi'));

const router = createBrowserRouter([
  {
    path: '/',
    element: <Suspense fallback="loading"><IndexPage /></Suspense>
  },
  {
    path: "/record",
    element: <Suspense fallback="loading"><RecordPage /></Suspense>
  },
  {
    path: '*',
    element: <Suspense fallback="loading"><IndexPage /></Suspense>
  }
]);

const root = ReactDOM.createRoot(
  document.getElementById('root') as HTMLElement
);

root.render(
  <React.StrictMode>
    <RouterProvider router={router} />
  </React.StrictMode>
);
